<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>商品列表</title>

<link rel="stylesheet" type="text/css" href="<?php echo theme_url('css/common.css');?>" />
<link rel="stylesheet" type="text/css" href="<?php echo asset_url('js/bootstrap/css/bootstrap.min.css');?>" />
<link rel="stylesheet" type="text/css" href="<?php echo asset_url('js/bootstrap/css/bootstrap-responsive.min.css');?>" />
<script type="text/javascript" src="<?php echo asset_url('js/jquery/jquery.js');?>"></script>

<script type="text/javascript">
	$(document).ready(function(){

		//搜索
		$('.search').click(function(){
			art.dialog({
				"id" : "add_sku_dialog",
				"title" : "供应商搜索",
				"content" : '<form id="search" action="<?php echo admin_url('goods/search');?>" method="GET"><input type="text" name="keywords" value="" class="input" style="width:200px;" /></form>',
				"initialize" : function(){
					$('#search').find(':input').first().focus();
				},
				"button" : [
					{
						"value" : "确定",
						"callback" : function(){
							if ($('#search').find(':input').first().val() == '')
							{
								$('#search').find(':input').first().focus().css('border-color', 'red');
								return false;
							}
							$('#search').submit();
						}
					},
					{
						"value" : "取消"
					}
				]
			});
		});

	});
</script>
</head>
<body>

	<?php echo widget('admin/header');?>

	<div id="wrap" class="container">
		
		<div class="btn-toolbar">
			<div class="btn-group">
				<a href="<?php echo admin_url('goods/insert');?>" class="btn">添加商品</a>
			</div>
			<div class="btn-group">
				<button class="btn">搜索</button>
			</div>
			<div class="btn-group">
				<button class="btn dropdown-toggle" data-toggle="dropdown">导出 <span class="caret"></span></button>
				<ul class="dropdown-menu">
					<li><a href="#">EXCEL</a></li>
					<li><a href="#">文本</a></li>
				</ul>
			</div>
		</div>

		<table class="table table-bordered">
			<thead>
				<tr>
					<th width="100">ID</th>
					<th>名称</th>
					<th width="100">分类</th>
					<th width="50">价格</th>
					<th width="100">库存</th>
					<th width="50">状态</th>
					<th width="200">操作</th>
				</tr>
			</thead>
			<tbody>
				<?php
					foreach ($list as $row)
					{
				?>
				<tr class="t_center">
					<td><?php echo $row['id'];?></td>
					<td><?php echo $row['name'];?></td>
					<td><a href="<?php echo admin_url('goods/index', array('category_id' => $row['category_id']));?>"><?php echo $row['category_name'];?></a></td>
					<td><?php echo $row['sale_price'];?> 元</td>
					<td><?php echo $row['stock'];?></td>
					<td><?php echo $row['on_sale'] == 1 ? '<span class="green">上架</span>' : '<span class="green">下架</span>';?></td>
					<td>
						<a href="<?php echo admin_url('goods/update', array('id' => $row['id']));?>">修改</a>
						<a href="<?php echo admin_url('goods/delete', array('id' => $row['id']));?>" class="delete">删除</a>
					</td>
				</tr>
				<?php
					}
				?>
			</tbody>
		</table>
		
		<div class="pager">
			共条<?php echo $page->rows();?>记录
			<?php echo $page->first();?>
			<?php echo $page->index();?>
			<?php echo $page->last();?>
		</div>
		
	</div>

	<?php echo widget('admin/footer');?>

</body>
</html>